package main

import (
	"carmanager/controller"
	"carmanager/middware"

	"github.com/gin-gonic/gin"
)

func main() {

	r := gin.Default()
	loginGroup := r.Group("/system")
	{
		login := controller.LoginController{}
		loginGroup.GET("/Login", login.Login)
		loginGroup.POST("/Regist", login.Regist)
	}
	roleGroup := r.Group("/Role")
	{
		roleCtr := controller.NewRoleController()
		roleGroup.POST("/List", roleCtr.List)
		roleGroup.POST("/Add", roleCtr.Add)
		roleGroup.POST("/Update", roleCtr.Update)
		roleGroup.POST("/Del", roleCtr.Del)
	}
	placeGroup := r.Group("/place")
	{
		plactCtr := controller.NewPlaceController()
		placeGroup.POST("/List", plactCtr.List)
		placeGroup.POST("/Add", plactCtr.Add)
		placeGroup.POST("/Update", plactCtr.Update)
		placeGroup.POST("/Del", plactCtr.Del)
	}
	userGroup := r.Group("/user")
	{
		userCtr := controller.NewUserController()
		userGroup.POST("/GetUserInfo", userCtr.GetUserInfo)
		userGroup.POST("/List", userCtr.List)
		userGroup.POST("/Add", userCtr.Add)
		userGroup.POST("/Update", userCtr.Update)
		userGroup.POST("/Del", userCtr.Del)
	}

	carGroup := r.Group("/car")
	{
		userCtr := controller.NewCarController()
		carGroup.POST("/List", userCtr.List)
		carGroup.POST("/MyList", userCtr.MyList)

		carGroup.POST("/StopCar", userCtr.StopCar)

		carGroup.POST("/Update", userCtr.Update)
		carGroup.POST("/Add", userCtr.Add)
		carGroup.POST("/Del", userCtr.Del)

		carGroup.GET("/OutBoud", userCtr.OutBoud)
	}
	r.Use(middware.MiddleWare())
	r.Run(":8080")
}
